
//
//  QZHairHeadCell.m
//  SmallShoppingCenter
//
//  Created by 上官惠阳 on 15/10/14.
//  Copyright (c) 2015年 上官惠阳. All rights reserved.
//

#import "QZHairHeadCell.h"
#import "QZHairsImageModel.h"
@implementation QZHairHeadCell

- (void)awakeFromNib {
    // Initialization code
    self.scrollView.delegate = self;
    [self.collectionBtn setImage:[UIImage imageNamed:@"喜欢-图标"] forState:UIControlStateNormal];
    [self.collectionBtn setImage:[UIImage imageNamed:@"喜欢-图标-选中"] forState:UIControlStateSelected];
}

-(void)addImageViewToScrollWithArr:(NSArray *)arr
{
    
    if (arr.count== 1) {
        self.pageControl.hidden = YES;
    }
    self.pageControl.numberOfPages = arr.count;
    CGFloat scrollHeight = self.scrollView.frame.size.height;
    self.scrollView.contentSize = CGSizeMake(WIDTH*arr.count, scrollHeight);
    self.scrollView.pagingEnabled = YES;
    for (int i = 0; i < arr.count; i ++) {
        QZHairsImageModel *model = arr[i];
        
        UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(i*WIDTH, 0, WIDTH, scrollHeight)];
        imageView.contentMode = UIViewContentModeScaleAspectFill;
        [imageView sd_setImageWithURL:[NSURL URLWithString:model.imgPath] placeholderImage:[UIImage imageNamed:@"1123.jpg"]];
        imageView.userInteractionEnabled = YES;
        [self.scrollView addSubview:imageView];
    }
    
    self.pageControl.numberOfPages = arr.count;
}
#pragma mark UIScrollViewDelegate
-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
    NSInteger index = scrollView.contentOffset.x / scrollView.frame.size.width;
    self.pageControl.currentPage = index;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
